/**
 * 
 */
package com.effectivsocial.service.security;

import java.util.Collection;
import java.util.List;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import com.effectivsocial.domain.User;

/**
 * @author Dhrubo
 *
 */
public class SimpleUserDetails implements UserDetails {

	
	private static final long serialVersionUID = 1L;
	private User user;
	private List<GrantedAuthority> authorities;
	
	public SimpleUserDetails(User user,List<GrantedAuthority> authorities) {
		this.user = user;
		this.authorities = authorities;
	}
	
	/**
	 * @return the user
	 */
	public User getUser() {
		return user;
	}

	
	public Collection<GrantedAuthority> getAuthorities() {
		return authorities;
	}

	public String getPassword() {
		return user.getPassword();
	}

	public String getUsername() {
		return user.getEmail();
	}

	public boolean isAccountNonExpired() {
		return true;
	}

	
	public boolean isAccountNonLocked() {
		return true;
	}

	public boolean isCredentialsNonExpired() {
		return true;
	}
	
	public boolean isEnabled() {
		return !user.isLocked();
	}

}